package cn.app.android.sichuanxiaoke.com.xiaokeapp.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.jude.rollviewpager.adapter.StaticPagerAdapter;

import butterknife.OnClick;
import cn.app.android.sichuanxiaoke.com.xiaokeapp.R;
import cn.app.android.sichuanxiaoke.com.xiaokeapp.activity.HomePHPActivity;
import cn.app.android.sichuanxiaoke.com.xiaokeapp.utils.ConstantUtils;

/**
 * Created by weian on 2017/8/17.
 */

public class TestNormalAdapter extends StaticPagerAdapter implements View.OnClickListener {
    Context context;

    public TestNormalAdapter(Context context) {
        this.context = context;
    }

    private int[] imgs = {
            R.mipmap.chaye,
            R.mipmap.chaye,
            R.mipmap.chaye,
            R.mipmap.chaye,
    };
    @Override
    public View getView(ViewGroup container, int position) {
        ImageView view = new ImageView(container.getContext());
        view.setImageResource(imgs[position]);
        view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        view.setOnClickListener(this);
        return view;
    }

    @Override
    public int getCount() {
        return imgs.length;
    }

    @Override
    public void onClick(View v) {
        Intent intent=new Intent(context, HomePHPActivity.class);
        intent.putExtra("URL", ConstantUtils.TEST_TEA_URL);
        context.startActivity(intent);
    }
}
